package cn.kongwg.boot.controller;

import cn.kongwg.boot.entity.User;
import cn.kongwg.boot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author kongwg
 * @create 2021-03-15 23:10
 */
@Controller
public class TableController {

    @Autowired
    private UserService userService;

    @GetMapping("/basic_table")
    public String basic() {

        return "table/basic_table";
    }

    @GetMapping("/dynamic_table")
    public String dynamic(Model model) {
     /*   User kongwg1 = new User("kongwg1", "1234");
        User kongwg2 = new User("kongwg2", "1234");
        User kongwg3 = new User("kongwg3", "1234");
        User kongwg4 = new User("kongwg4", "1234");
        List<User> list = new ArrayList<>();
        list.add(kongwg1);
        list.add(kongwg2);
        list.add(kongwg3);
        list.add(kongwg4);

        model.addAttribute("users", list);*/
        List<User> allUser = userService.findAllUser();
        model.addAttribute("users", allUser);

        return "table/dynamic_table";
    }

    @GetMapping("/editable_table")
    public String editable() {
        return "table/editable_table";
    }

    @GetMapping("/pricing_table")
    public String pricing() {
        return "table/pricing_table";
    }

    @GetMapping("/responsive_table")
    public String responsive() {
        return "table/responsive_table";
    }


}
